
//
//  DoorSystemCheckTableViewCell.m
//  RONGAO
//
//  Created by ZhangYeKun on 2017/2/24.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DoorSystemCheckTableViewCell.h"

NSString * const kCheckTableViewCellIdentifier = @"kCheckTableViewCellIdentifier";

@interface DoorSystemCheckTableViewCell ()

/** 图片 **/
@property(nonatomic,strong) UIButton *iconButton;
/** 标题 **/
@property(nonatomic,strong) UILabel *iconNameLabel;
@end

@implementation DoorSystemCheckTableViewCell


- (instancetype)init{
    
    if ([super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCheckTableViewCellIdentifier]) {
        
        [self masLayoutSubview];
        
    }
    
    return self;
    
}

- (void)setupViewWithConfig:(NSDictionary *)config{
    
    [self.iconButton setImage:[UIImage imageNamed:config[@"nor_img"]] forState:UIControlStateNormal];
    [self.iconButton setImage:[UIImage imageNamed:config[@"sel_img"]] forState:UIControlStateSelected];
    self.iconNameLabel.text = config[@"title"];
    
}

- (UIButton *)iconButton{
    
    if (!_iconButton) {
        
        __weak UIView *superView = self;
        _iconButton = [[UIButton alloc]init];
        [superView addSubview:_iconButton];
        _iconButton.userInteractionEnabled = NO;
        
    }
    
    return _iconButton;
    
}

- (UILabel *)iconNameLabel{
    
    if (!_iconNameLabel) {
        
        __weak UIView *superView = self;
        _iconNameLabel = [[UILabel alloc]init];
        [superView addSubview:_iconNameLabel];
        [_iconNameLabel setFont:[UIFont systemFontOfSize:14.f]];
        _iconNameLabel.textColor = [UIColor grayColor];
        
    }
    
    return _iconNameLabel;
    
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self;
    [self.iconButton mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.centerY.mas_equalTo(superView.mas_centerY);
        
    }];
    [self.iconNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.top.mas_equalTo(self.iconButton.mas_bottom).mas_offset(5);
        
    }];
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
